<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>中国传媒大学设备预约平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="{$projectUrl}/css/admin_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{$projectUrl}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/globalJsFunction.js"></script>
<script type="text/javascript">

</script>
</head>
<body>
<div class="main">
  <div class="main_resize">
    <div class="main_left">
      {include file=include/headerLogo.html}
      <div class="clr"></div>
      {include file=include/adminLeftMenu.html}
      <div class="clr"></div>
      <h2>&nbsp;</h2>
    </div>
    <div class="main_right">
      {include file=include/headerLogin.html}

      <div class="clr" style="background-color:#C63; height:1px;">&nbsp;</div>
      <div>
      {include file=include/adminTopMenu.html}
      </div>
      <div class="clr">
      	<p><img src="{$projectUrl}/images/addCamera.jpg" width="30px" height="20px"><span style="font-color:#C60; font-size:16px;">添加设备</span>
          <span style="font-color:#C60; font-size:16px; display:inline;"></span>(总个数:{$devicesNumber})</p>
      	 <!--创建设备-->

                <div id = "create_device_name" style="font-size:14px;">
                <form action="device.php?action=adddevice" method="post">
                <input type="hidden" name="action" id="action" value="adddevice"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px">
                    	<tr>
                    		<td>编号/条形码</td>
                    		<td>名称</td>
                    		<td>类型</td>
                    		<td>维护情况</td>
                    		<td>其他信息</td>
                    		<td>添加</td>
                    	</tr>
                    	<tr>
                    		<td><input type="text" id="barcode" name="barcode" size="14"/></td>
                    		<td><input type="text" id="name" name="name" size="14"/></td>
                    		<td>
                    			<select id="type" name="type">
	                        <option value="0" selected="selected">按天</option>
	                        <option value="1">按节</option>
	                        </select>
                    		</td>
                    		<td>
                    			<input type="text" id="maintenance" name="maintenance" size="14"/>
                    		</td>
                    		<td>
                    			<input type="text" id="info" name="info" size="14"/>
                    		</td>
                    		<td><input type="image" src="{$projectUrl}/images/add1.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
                <div>
                  <span style="align:center; color:red; font-size:12px">{$insertMessage}</span>
                  </div>
                <!--创建用户结束-->
      </div>

      <!-- 搜索用户并且进行修改 -->
      <div class="clr">
       <!--全部用户的列表-->
                <div>
                	<p>
                		<span>{if $searchNote eq ""}输入编号或者名字进行搜索
                		{else}{$searchNote}
                		{/if}
                		</span>
                		<span style="float:right">
					        <form id="form1" name="form1" method="get" action="device.php">
					        	 <input type="hidden" name="action" id="action" value="searchDevice"/>
                                <input type="text" class="keywords" id="keyword" name="keyword" maxlength="50" value="{$keyword}"/>
                                <input name="b" type="submit" class="button" value="搜索" />
					        </form>
					        </span></p>
                <form id="devicelist_form" action="device.php?action=deletedevice&pageIndex={$pageIndex}" method="post" onsubmit="return window.confirm('确定删除？');">
                <input type="hidden" name="action" id="action" value="deletedevice"/>
                    <table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
                    <tr valign="top"  style="background-color:#C60">
                        <td>&nbsp;</td>
                        <td>编号</td>
                        <td>名称</td>
                        <td>类型</td>
                        <td>维护</td>
                        <td>备注</td>
                        <td>目前状态</td>
                        <td>操作</td>
                    </tr>
                    {foreach from=$devices item=device name=devicelist}
                    <tr valign="top" onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                        <td><input type="checkbox" id="devices[]" name="devices[]" value="{$device.id}"/></td>
                        <td><span title="{$device.barcode}">{$device.barcode|truncate:10:"..."|escape:'html'}</span></td>
                        <td><span title="{$device.name}">{$device.name|truncate:20:"..."|escape:'html'}</span></td>
                        <td>{$device.type}</td>
                        <td><span title="{$device.maintenance}">{$device.maintenance|truncate:20:"..."|escape:'html'}</span></td>
                        <td><span title="{$device.info}">{$device.info|truncate:20:"..."|escape:'html'}</span></td>
                        <td><span title="{$device.remain}">{$device.remain|truncate:20:"..."|escape:'html'}</span></td>
                        <td><a href="device.php?action=edit&id={$device.id}&pageIndex={$pageIndex}#editDeviceDiv">编辑</a></td>
                    </tr>
                    {/foreach}


                    <tr><td align="right" colspan="2">
                        <input type="button" value="全选" onclick='chkall("devicelist_form")' />
                        <input type="reset" value="不选" />
                        </td>
                        <td align="left" colspan="3">
                        <input type="submit" value="删除选中"/>
                        </td>
                    </tr>
                     <tr>
                    <td colspan="8" align="center">
                    <a href="device.php?pageIndex={$leftPageIndex}">&lt;</a>

                    {section start=$leftMostPageIndex loop=$pageIndex step=1 name=pagesection}
                    <a href="device.php?pageIndex={$smarty.section.pagesection.index}">
                    {$smarty.section.pagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}
                    <span style="font-size:18px;"><Strong><bold>{$pageIndex}</bold></Strong>&nbsp;</span>
                    {section start=$pageIndex+1 loop=$rightMostPageIndex+1 step=1 name=rightpagesection}
                    <a href="device.php?pageIndex={$smarty.section.rightpagesection.index}">
                    {$smarty.section.rightpagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}

                    <a href="device.php?pageIndex={$rightPageIndex}">&gt;</a>
                    </td>
                    </tr>
                    </table>
                </form>
                </div>
                <!--全部用户的列表-->
      </div>
      <!-- 搜索用户并且进行修改 结束-->
      <div class="clr"></div>
      {if $editDevice.id neq ''}
      <div class="clr" id="editDeviceDiv">
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px">
      		<span style="font-color:#C60; font-size:16px;">编辑设备信息</span></p>
                <div id = "modify_device" style="font-size:14px;">
                <form action="device.php?id={$editDevice.id}&pageIndex={$pageIndex}#editDeviceDiv" method="post">
                <input type="hidden" name="action" id="action" value="modifydevice"/>
                <input type="hidden" name="deviceid" id="deviceid" value="{$editDevice.id}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px;">
                    	<tr>
                    		<td>编号</td><td>{$editDevice.id}</td>
                    	</tr>
                    	<tr>
                    		<td>名称</td><td><input type="text" id="name" name="name" size="30" value="{$editDevice.name}"/></td>
                    		</tr>
                    	<tr>
                    		<td>二维码</td><td>{$editDevice.barcode}</td>
                    		</tr>
                    	<tr>
                    		<td>类型</td>
                    		<td>
                    			<select id="type" name="type">
	                        <option value="0" {if $editDevice.type eq 0}selected="selected"{/if}>器材</option>
	                        <option value="1" {if $editDevice.type eq 1}selected="selected"{/if}>教室</option>
	                        <option value="2" {if $editDevice.type eq 2}selected="selected"{/if}>服装</option>
	                        </select>
                    		</td>
                    		</tr>
                    	<tr>
                    		<td>所属类别</td>
                    		<td>
                    			{$editDevice.categories}
                    		</td>
                    		</tr>
                    	<tr>
                    		<td>维护信息:</td>
                    		<td><input type="text" id="maintenance" name="maintenance" size="20" value="{$editDevice.maintenance}"/></td>
                    		</tr>
                    	<tr valign="top">
                    		<td>介绍</td><td><textarea type="text" id="info" name="info" rows="2" cols="20">{$editDevice.info}</textarea></td>
                    		</tr>
                    	<tr>
                    		<td>创建时间</td><td>{$editDevice.createtime}</td>
                    	</tr>
                    <tr>
                    		<td>保存</td><td><input type="image" src="{$projectUrl}/images/save.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
      </div>
      
      
      
      <div class="clr" id="uploadPictures">
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px"/><span style="font-color:#C60; font-size:14px;">上传图片</span></p>
      	<span style="color:red">{$uploadFileNotice}</span>
	      <form name="formupload" method="post" enctype="multipart/form-data" action="device.php?action=upload&id={$editDevice.id}&pageIndex={$pageIndex}#uploadPictures">
	    		<input type="file" name="picture"/>
	    		<input type="hidden" name="action" value="upload"/>
	    		<input type="hidden" name="id" id="id" value="{$editDevice.id}"/>
	    		<span style="font-size:12px">图片描述</span>
	    		<input type="text" name="pictureDescription"/>
	    		<input type='submit' name='submit' value='确定'/>
				</form>
			</div>
			<div class="clr" id="showPictures">
           <div id = "modify_user" style="font-size:14px;">
                    <table bgcolor="#FFFFFF" width="100%" >
                    	<tr style="background-color:#C60">
                    		<td>小图展示</td>
                    		<td>介绍</td>
                    		<td>保存</td>
                    		<td>删除</td>
                    	</tr>
                    	{foreach from=$pictures item=pictureitem name=picturelist}
                    	<form action=""device.php?id={$editDevice.id}&pageIndex={$pageIndex}#uploadPictures" method="post">
			                <input type="hidden" name="action" id="action" value="modifyPicture"/>
			                <input type="hidden" name="pid" id="pid" value="{$pictureitem.id}"/>
                    	<tr>
                    		<td><a href="{$pictureitem.pictureUrl}" target="_blank"><img src="{$pictureitem.pictureUrl}" width="60" height="50" /></a>
                    			</td>
                    		<td><input type="text" id="note" name="note" size="30" value="{$pictureitem.picture_note}"/></td>
                    		<td><input type="image" src="{$projectUrl}/images/save.jpg" class="button"/></td>
                    		<td><a href="device.php?action=removePicture&id={$editDevice.id}&pid={$pictureitem.id}&pageIndex={$pageIndex}#showPictures">删除</a></td>
                    	</tr>
                    	</form>
                    	{/foreach}
                    </table>
          </div>
			</div>
      
      <!-- 编辑设备与课程的对应信息 -->
      <div class="clr" id="editDeviceCourseDiv" >
      	{if $addDeviceCourseNotice neq ''}
      	<p style="color:red"><Strong>{$addDeviceCourseNotice}</Strong></p>
      	{/if}
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px"><span style="font-color:#C60; font-size:16px;">编辑所属课程({$deviceCourses|@count})</span></p>
                <div id = "modify_device" style="font-size:14px;">
                <form action="device.php?id={$editDevice.id}&pageIndex={$pageIndex}#editDeviceCourseDiv" method="post">
                <input type="hidden" name="action" id="action" value="addDeviceCourse"/>
                <input type="hidden" name="deviceid" id="deviceid" value="{$editDevice.id}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px;">
                    	<tr>
                    		<td>设备名字:{$editDevice.name}({$editDevice.barcode})</td>
                    		<td>类型:
                    			{if $editDevice.type eq "0"}
                    			器材
                    			{elseif $editDevice eq "1"}
                    			教师
                    			{else}
                    			服装
                    			{/if}
                    		</td>
                    		<td>课程:
                    			<select id="courseid" name="courseid">
	                        {foreach from=$courses item=course name=courseslist}
	                        <option value="{$course.id}">{$course.name}</option>
	                        {/foreach}
	                        </select>
                    		</td>
                    		<td><input type="image" src="{$projectUrl}/images/add1.jpg" class="button"/>
                    			</td>
                    	</tr>
                    </table>
                </form>
                </div>
      </div>
      <!-- 展现设备所属于的课程-->
      <div class="clr" id="saveremovedevicecoursediv"> 
      	<table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
                    <tr valign="top"  style="background-color:#C60">
                    		<td>创建时间</td>
                        <td>课程名字</td>
                        <td>删除</td>
                    </tr>
                    {foreach from=$deviceCourses item=deviceCourse name=deviceCourseslist}
                    <tr valign="top"  onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                    		<form action="device.php?#saveremovedevicecoursediv" method="post">
                        <td>{$deviceCourse.createtime}</td>
                        <td>{$deviceCourse.courseName}</td>
                       	<td><a href="device.php?action=removedevicecourse&id={$editDevice.id}&pageIndex={$pageIndex}&courseid={$deviceCourse.cid}&pageIndex={$pageIndex}#saveremovedevicecoursediv">
                       		删除
                       		</a>
                       	</td>
                    </tr>
                    {/foreach}
        </table>	
      </div>
      <!-- 编辑用户与课程的对应信息 end-->
      <!-- 编辑设备结束 -->
      
      
			{/if}
    </div>
    <div class="clr"></div>
  </div>
  <div class="footer">
    {include file=include/footer.html}
  </div>
</div>
<div align=center></div></body>
</html>
